package Impl;

import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAPackage.ServantNotActive;
import org.omg.PortableServer.POAPackage.WrongPolicy;

import jobFactoryItf.CallBack;
import jobFactoryItf.CallBackHelper;
import jobFactoryItf.Job;
import jobFactoryItf.JobFactoryHelper;
import jobFactoryItf.JobFactoryPOA;
import jobFactoryItf.JobHelper;
import jobFactoryItf.JobHolder;

public class JobFactoryImpl extends JobFactoryPOA {
	
	private POA rootpoa;
	
	public JobFactoryImpl(POA rootpoa) {
		super();
		this.rootpoa = rootpoa;
	}
	
	@Override
	public void creer_job(short id, JobHolder j, CallBack c) {
		org.omg.CORBA.Object ref = null;
		JobImpl job = new JobImpl(id, c);
		
		try {
			ref = rootpoa.servant_to_reference(job);
			
		} catch (ServantNotActive | WrongPolicy e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		j.value = JobHelper.narrow(ref);
	}
}
